package cn.wp.ewallet.wallet.web.controller;

import cn.wp.common.core.Wp;
import cn.wp.common.core.dto.WpResult;
import cn.wp.common.core.web.annotation.ClearInterceptor;
import cn.wp.common.core.web.interceptor.LoginInterceptor;
import cn.wp.ewallet.wallet.extension.constant.EwalletWalletConstant;
import cn.wp.ewallet.wallet.model.dto.MentionMoneyDto;
import cn.wp.ewallet.wallet.model.dto.MentionMoneyInfoDto;
import cn.wp.ewallet.wallet.model.dto.MoneyChangeParamDto;
import cn.wp.ewallet.wallet.service.MentionMoneyInfoService;
import cn.wp.ewallet.wallet.service.MoneyChangeService;
import cn.wp.ewallet.wallet.service.WalletInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 提币申请单-控制层
 * Created by zhangyongli on 2020/01/09
 */
@RestController
@RequestMapping(Wp.WebContext + "/ewallet/wallet/mentionMoney")
@Api(tags="提币申请单")
public class MentionMoneyInfoController {

    @Autowired
    private MentionMoneyInfoService mentionMoneyInfoService;

    @Autowired
    private MoneyChangeService moneyChangeService;

    @Autowired
    private WalletInfoService walletInfoService;

    /**
     * 处理提币申请单
     * @param mentionMoneyDto
     * @return
     */
    @PostMapping("/handerMentionMoneyOrder")
    @ApiOperation("处理提币申请单")
    public WpResult handlerMentionMoneyOrder(MentionMoneyDto mentionMoneyDto){
        return moneyChangeService.withdrawalMoneyHandle(mentionMoneyDto);
    }

    /**
     * 提交 提币申请单
     * @param moneyChangeParamDto
     * @return
     */
    @PostMapping("/applyMentionMoneyOrder")
    @ApiOperation("提交提币申请单")
    public WpResult applyMentionMoneyOrder(MoneyChangeParamDto moneyChangeParamDto){
        //校验交易密码
       if (!walletInfoService.checkTransPwd(moneyChangeParamDto.getTransPwd())) {
            return new WpResult().failure(EwalletWalletConstant.CHECK_TRANSPWD_FAILED_CODE, "交易密码校验失败");
        }
        return moneyChangeService.withdrawalMoneyApply(moneyChangeParamDto);
    }



}